<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
	<link href="https://cdn.bootcss.com/animate.css/3.7.2/animate.css" rel="stylesheet">
	<style>
		/*不加name默认以v开头的类目执行动画*/
		.v-enter,.v-leave-to{
			opacity: 0;
		}
		.v-enter-active,.v-leave-active{
			transition: opacity 1s;
		}
	</style>
</head>
<body>
	<div id="root">
		<!-- mode=out-in:先隐藏再展示 -->
		<transition mode="out-in">
			<!-- 元素在切换的时候会去复用DOM，需要添加一个key -->
			<div v-if="show" key="hello">Hello world</div>
			<div v-else key="bye">Bye World</div>
		</transition>	
		<button @click="handleClick">切换</button>
	</div>
	<script type="text/javascript">
		var vm=new Vue({
			el:"#root",
			data:{
				show:true
			},
			methods:{
				handleClick:function(){
					this.show=!this.show
				}
			}
		})
	
	</script>
</body>
</html>